package com.ziyun.pop.web.modules.freightages.controller;

import com.utility.JsonUtils;
import com.utility.New;
import com.utility.http.HttpUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 运费地址表
 *
 * @author 
 * @email 
 * @date 2018-08-10 15:38:32
 */
@RestController
@RequestMapping("freightages/freightarea")
public class FreightAreaController {

    @Value("${erpApi}")
    private String erpApi ;


//    /**
//     * 列表
//     */
//    @RequestMapping("/list")
//    @RequiresPermissions("freightages:freightarea:list")
//    public R list(@RequestParam Map<String, Object> params){
//        PageUtils page = freightAreaService.queryPage(params);
//
//        return R.ok().put("page", page);
//    }
//
//
//    /**
//     * 信息
//     */
//    @RequestMapping("/info/{freightAreaId}")
//    @RequiresPermissions("freightages:freightarea:info")
//    public R info(@PathVariable("freightAreaId") Integer freightAreaId){
//        FreightAreaEntity freightArea = freightAreaService.selectById(freightAreaId);
//
//        return R.ok().put("freightArea", freightArea);
//    }
//
//    /**
//     * 保存
//     */
//    @RequestMapping("/save")
//    @RequiresPermissions("freightages:freightarea:save")
//    public R save(@RequestBody FreightAreaEntity freightArea){
//        freightAreaService.insert(freightArea);
//
//        return R.ok();
//    }
//
//    /**
//     * 修改
//     */
//    @RequestMapping("/update")
//    @RequiresPermissions("freightages:freightarea:update")
//    public R update(@RequestBody FreightAreaEntity freightArea){
//        ValidatorUtils.validateEntity(freightArea);
//        freightAreaService.updateAllColumnById(freightArea);//全部更新
//
//        return R.ok();
//    }
//
//    /**
//     * 删除
//     */
//    @RequestMapping("/delete")
//    @RequiresPermissions("freightages:freightarea:delete")
//    public R delete(@RequestBody Integer[] freightAreaIds){
//        freightAreaService.deleteBatchIds(Arrays.asList(freightAreaIds));
//
//        return R.ok();
//    }
    /**
     * 远程调用方法封装
     * @param params
     * @return
     */
    private Map<String, Object> remoteProcedureCall(@RequestParam Map<String, Object> params, String path) {
        String url = erpApi + path;
        Map<String, Object> paramHeaderMap = New.hashMap();
        Map<String, Object> paramBodyMap = New.hashMap();
        paramBodyMap.put("params",params);
        String response = HttpUtils.doPost(url, paramHeaderMap, JsonUtils.map2String(paramBodyMap));
        return com.ziyun.pop.common.utils.JsonUtils.jsonToMap(response);
    }

}
